DEFINE VARIABLE part AS CHARACTER FORMAT "x(16)".
DEFINE VARIABLE cst AS CHARACTER FORMAT "x(16)".
DEFINE VARIABLE rat AS CHARACTER FORMAT "x(16)".
DEFINE VARIABLE mfg AS CHARACTER FORMAT "x(16)".
DEFINE VARIABLE sim AS CHARACTER FORMAT "x(16)".
DEFINE VARIABLE dte AS CHARACTER FORMAT "x(16)".

ASSIGN sim = "CM2004-05".
ASSIGN dte = "04/05/06".



INPUT FROM VALUE("c:\qadguicli\doc\05bal.csv").

 

REPEAT ON ERROR UNDO, LEAVE:
 

    IMPORT DELIMITER "," part cst rat mfg NO-ERROR. 

    DISPLAY part cst rat mfg WITH DOWN FRAME a.
    

    IF NOT( part BEGINS "P")  THEN NEXT.
/* IF part = "p15-3285305" THEN DO: */
   
   FIND FIRST csta_hist WHERE csta_part = part AND csta_sim = sim EXCLUSIVE-LOCK NO-ERROR.
   IF AVAILABLE csta_hist THEN DO:
       ASSIGN csta_dec01 = DECIMAL(cst)
              csta_dec02 = DECIMAL(rat)
              csta_dec03 = DECIMAL(mfg)
              csta_dte01 = dte
       NO-ERROR.
   END.
   ELSE DO:
       CREATE csta_hist.
       ASSIGN csta_sim = sim
              csta_part = part
              csta_dec01 = DECIMAL(cst)
              csta_dec02 = DECIMAL(rat)
              csta_dec03 = DECIMAL(mfg)
              csta_dte01 = dte
       NO-ERROR.
   END.
   DOWN WITH FRAME a.
    
/*    DISP csta_part csta_dec01 csta_dec02 . */

END. 

/* 
END. */


INPUT CLOSE.
